<?php
	Class Employee_model extends CI_Model{
		public function __construct(){
			parent::__construct();
		}
		public function listAll(){
			$query = $this->db->get_where('employee',array('status'=>'Y'));
			if($query->num_rows()>0){
				return $query->result();
			}else{
				return null;
			}
		}
		public function addThis($items){
			$query = $this->db->insert('employee',$items);
			return $this->db->affected_rows();
		}
		public function listThis($id){
			$query = $this->db->get_where('employee',array('id'=>$id));
			if($query->num_rows()>0){
				return $query->result();
			}
		}
		public function updateThis($id){
			$data = array(
				'name'=>$this->input->post('name'),
				'address'=>$this->input->post('address'),
				'email'=>$this->input->post('email'),
			);
			$this->db->where('id',$id);
			$this->db->update('employee',$data);
			return $this->db->affected_rows();
		}
		public function fire($id){
			$data = array(
				'status'=>'N',
			);
			$this->db->where('id',$id);
			$this->db->update('employee',$data);
			return $this->db->affected_rows();
		}
	}
?>